package com.shiguo365.market.display.activity;

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.Toast;

import com.shiguo365.market.R;
import com.shiguo365.market.display.adapter.OrderListAdapter;
import com.shiguo365.market.display.base.BaseActivity;
import com.shiguo365.market.display.util.RefreshUtils;

import butterknife.BindView;
import butterknife.ButterKnife;

public class OrderListActivity extends BaseActivity implements SwipeRefreshLayout.OnRefreshListener {

    private LinearLayoutManager mLayoutManager;
    public String[] datas={"11111","22222","33333","44444","55555","6666666","77777","88888","99999","10000","10001"};
    @BindView(R.id.order_list_refresh_layout)
    protected SwipeRefreshLayout refreshLayout;
    @BindView(R.id.my_recycler_view_orderlist)
    protected RecyclerView mRecyclerView;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_order_list);
        ButterKnife.bind(this); //ButterKnife初始化

        mLayoutManager = new LinearLayoutManager(this);
        mRecyclerView.setLayoutManager(mLayoutManager);
//如果可以确定每个item的高度是固定的，设置这个选项可以提高性能
        mRecyclerView.setHasFixedSize(true);
//创建并设置Adapter

        OrderListAdapter mAdapter = new OrderListAdapter(datas);
        mRecyclerView.setAdapter(mAdapter);

        RefreshUtils.initOnCreate(refreshLayout, this);
        RefreshUtils.refreshOnCreate(refreshLayout, this);

    }


    @Override
    public void onRefresh() {
        //添加刷新代码

        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                refreshLayout.setRefreshing(false);
            }
        }, 2000);


    }
}
